/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package victoralbertos.io.ohos.net;

import java.util.List;

import io.rx_cache.entities.Repo;
import io.rx_cache.entities.User;
import retrofit2.Response;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.Path;
import retrofit2.http.Query;
import rx.Observable;

/**
 * Retrofit接口类
 *
 * @author name
 * @since 2021-05-30
 */
public interface RestApi {
    /**
     * 基础地址
     */
    String URL_BASE = "https://api.github.com/"; // 基础地址
    /**
     * head
     */
    String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json"; // head

    /**
     * 请求用户列表
     *
     * @param lastIdQueried
     * @param perPage
     * @return Observable
     */
    @Headers({HEADER_API_VERSION})
    @GET("/users")
    Observable<List<User>> getUsers(@Query("since") int lastIdQueried, @Query("per_page") int perPage);

    /**
     * 请求用户信息
     *
     * @param userName
     * @return Observable
     */
    @Headers({HEADER_API_VERSION})
    @GET("/users/{username}/repos")
    Observable<List<Repo>> getRepos(@Path("username") String userName);

    /**
     * 请求用户列表
     *
     * @param username
     * @return Observable
     */
    @Headers({HEADER_API_VERSION})
    @GET("/users/{username}")
    Observable<Response<User>> getUser(@Path("username") String username);
}
